package com.bw.shop.controller;

import com.bw.common.domain.Car;
import com.bw.common.domain.Logs;
import com.bw.common.domain.Lx;
import com.bw.common.result.Result;
import com.bw.shop.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author：HaoYunde
 * @Package：com.bw.shop.controller
 * @Project：hyd-boot
 * @name：CarController
 * @Date：2024/6/17 17:10
 */
@RestController
@RequestMapping("/car")
public class CarController {
    @Autowired
    private CarService carService;
    @Autowired
    private StringRedisTemplate redisTemplate;


    /**
     * 查询购物车
     * @return
     */
    @GetMapping("findCarList")
    public Result<List<Car>> findCarList(){
        List<Car> list=carService.findCarList();
        return Result.success(list);
    }


    /**
     * 查询记录表
     * @return
     */
    @GetMapping("findLogsList")
    public Result<List<Logs>> findLogsList(){
        List<Logs> list=carService.findLogsList();
        return Result.success(list);
    }


    /**
     * 添加记录
     * @param logs
     * @return
     */
    @PostMapping("/addLogs")
    public Result addLogs(@RequestBody Logs logs){
        return carService.addLogs(logs);
    }


    /**
     * 结算订单
     * @param price
     * @return
     */
    @Transactional
    @GetMapping("/updateAdminStatus")
    public Result updateAdminStatus(@RequestParam String price){
        return carService.updateAdminStatus(price);
    }


    /**
     * 申请退款
     */
    @GetMapping("/updateStatus")
    public Result updateStatus(@RequestParam Integer id){
        return carService.updateStatus(id);
    }

}
